<?php
defined('IN_ADMIN') or exit('No permission resources.');
$show_header = True;
include $this->admin_tpl('header');?>
<script type="text/javascript">
<!--
$(function(){
	SwapTab('setting','on','',4, '<?php echo $this->groupid; ?>');
})
//-->
</script>
<form action="<?php echo U('update');?>" method="post" id="myform">
<div class="pad-10">
    <div class="col-tab">
        <ul class="tabBut cu-li">
            <li id="tab_setting_base" <?php if ($this->groupid == 'base'): ?>class="on"<?php endif ?> onclick="SwapTab('setting','on','',4, 'base');"><?php echo L('setting_basic_cfg')?></li>
            <li id="tab_setting_safe" <?php if ($this->groupid == 'safe'): ?>class="on"<?php endif ?> onclick="SwapTab('setting','on','',4, 'safe');"><?php echo L('setting_safe_cfg')?></li>
            <li id="tab_setting_email" <?php if ($this->groupid == 'email'): ?>class="on"<?php endif ?> onclick="SwapTab('setting','on','',4, 'email');"><?php echo L('setting_mail_cfg')?></li>
            <li id="tab_setting_upload" <?php if ($this->groupid == 'upload'): ?>class="on"<?php endif ?> onclick="SwapTab('setting','on','',4, 'upload');"><?php echo L('setting_upload_cfg')?></li>
        </ul>
        
        <div id="div_setting_base" class="contentList pad-10">
        <table width="100%"  class="table_form">
            <tr>
                <th><?php echo L('webname')?></th>
                <td class="y-bg"><input type="text" class="input-text" name="setting[webname]" id="webname" size="30" value="<?php echo $setting['webname'];?>"/></td>
            </tr>

            <tr>
                <th><?php echo L('keyword')?></th>
                <td class="y-bg"><input type="text" class="input-text" name="setting[keyword]" id="keyword" size="50" value="<?php echo $setting['keyword'];?>"/></td>
            </tr> 
            <tr>
                <th><?php echo L('description')?></th>
                <td class="y-bg"><textarea name="setting[description]" id="description" cols="47" rows="6"><?php echo $setting['description'];?></textarea></td>
            </tr>
            <tr>
                <th><?php echo L('authkey')?></th>
                <td class="y-bg"><input type="text" class="input-text" name="setting[authkey]" id="authkey" size="30" value="<?php echo $setting['authkey'];?>"/>
                &nbsp;若留空，系统会自动重新生成加密密钥
                </td>
            </tr>

            <tr>
                <th><?php echo L('setting_default_theme');?></th>
                <td class="y-bg"><?php echo $form::select($style_list, $setting['default_style'], 'name="setting[default_style]" id="default_theme"', L('please_select'))?> &nbsp; <?php echo L('setting_default_theme_tips');?></td>
            </tr>
        </table>
        </div>

        <div id="div_setting_safe" class="contentList pad-10 hidden" style="display:none;">
        <table width="100%"  class="table_form">
            <tr>
                <th width="120"><?php echo L('setting_admin_log')?></th>
                <td class="y-bg"><input name="setting[admin_log]" value="1" type="radio" <?php echo ($setting['admin_log']) ? ' checked' : ''?>> <?php echo L('setting_yes')?>&nbsp;&nbsp;&nbsp;&nbsp;<input name="setting[admin_log]" value="0" type="radio" <?php echo (!$setting['admin_log']) ? ' checked' : ''?>> <?php echo L('setting_no')?></td>
            </tr>

            <tr>
                <th width="120"><?php echo L('setting_error_log')?></th>
                <td class="y-bg"><input name="setting[errorlog]" value="1" type="radio" <?php echo ($setting['errorlog']) ? ' checked' : ''?>> <?php echo L('setting_yes')?>&nbsp;&nbsp;&nbsp;&nbsp;<input name="setting[errorlog]" value="0" type="radio" <?php echo (!$setting['errorlog']) ? ' checked' : ''?>> <?php echo L('setting_no')?></td>
            </tr>

            <tr>
                <th><?php echo L('setting_error_log_size')?></th>
                <td class="y-bg"><input type="text" class="input-text" name="setting[setting_errorlog_size]" id="errorlog_size" size="5" value="<?php echo $setting['setting_errorlog_size'] ?>"/> MB</td>
            </tr>

            <tr>
                <th><?php echo L('setting_maxloginfailedtimes')?></th>
                <td class="y-bg"><input type="text" class="input-text" name="setting[maxloginfailedtimes]" id="maxloginfailedtimes" size="10" value="<?php echo $setting['maxloginfailedtimes'] ?>"/></td>
            </tr>

            <tr>
                <th><?php echo L('setting_minrefreshtime')?></th>
                <td class="y-bg"><input type="text" class="input-text" name="setting[minrefreshtime]" id="minrefreshtime" size="10" value="<?php echo $setting['minrefreshtime'];?>"/> <?php echo L('miao')?></td>
            </tr>
        </table>
        </div>

        <div id="div_setting_email" class="contentList pad-10 hidden" style="display:none;">
            <table width="100%"  class="table_form">
                <tr>
                    <th width="120"><?php echo L('setting_admin_email')?></th>
                    <td class="y-bg"><input type="text" class="input-text" name="setting[admin_email]" id="admin_email" size="30" value="<?php echo $setting['admin_email'];?>"/></td>
                </tr>                

                <tr>
                    <th width="120"><?php echo L('mail_type')?></th>
                    <td class="y-bg"><input name="setting[mail_type]" checkbox="mail_type" value="1" onclick="showsmtp(this)" type="radio" <?php echo ($setting['mail_type']) ? ' checked' : ''?>> <?php echo L('mail_type_smtp')?><input name="setting[mail_type]" checkbox="mail_type" value="0" onclick="showsmtp(this)" type="radio" <?php echo (!$setting['mail_type']) ? ' checked' : ''?> <?php if(substr(strtolower(PHP_OS), 0, 3) == 'win') echo 'disabled'; ?>/> <?php echo L('mail_type_mail')?> 
                    </td>
                </tr>

                <tbody id="smtpcfg" style="<?php if(!$setting['mail_type']) echo 'display:none'?>">
                    <tr>
                        <th><?php echo L('mail_server')?></th>
                        <td class="y-bg"><input type="text" class="input-text" name="setting[mail_server]" id="mail_server" size="30" value="<?php echo $setting['mail_server'];?>"/></td>
                    </tr>

                    <tr>
                        <th><?php echo L('mail_port')?></th>
                        <td class="y-bg"><input type="text" class="input-text" name="setting[mail_port]" id="mail_port" size="30" value="<?php echo $setting['mail_port'];?>"/></td>
                    </tr>
                    <tr>
                        <th><?php echo L('mail_from')?></th>
                        <td class="y-bg"><input type="text" class="input-text" name="setting[mail_from]" id="mail_from" size="30" value="<?php echo $setting['mail_from'];?>"/></td>
                    </tr>

                    <tr>
                        <th><?php echo L('mail_auth')?></th>
                        <td class="y-bg"><input name="setting[mail_auth]" checkbox="mail_auth" value="1" type="radio" <?php echo ($setting['mail_auth']) ? ' checked' : ''?>> <?php echo L('mail_auth_open')?><input name="setting[mail_auth]" checkbox="mail_auth" value="0" type="radio" <?php echo (!$setting['mail_auth']) ? ' checked' : ''?>> <?php echo L('mail_auth_close')?></td>
                    </tr>

                    <tr>
                        <th><?php echo L('mail_user')?></th>
                        <td class="y-bg"><input type="text" class="input-text" name="setting[mail_user]" id="mail_user" size="30" value="<?php echo $setting['mail_user'];?>"/></td>
                    </tr>
                    
                    <tr>
                        <th><?php echo L('mail_password')?></th>
                        <td class="y-bg"><input type="password" class="input-text" name="setting[mail_password]" id="mail_password" size="30" value="<?php echo $setting['mail_password'];?>"/></td>
                    </tr>
                </tbody>

                <tr>
                    <th><?php echo L('mail_test')?></th>
                    <td class="y-bg"><input type="text" class="input-text" name="mail_to" id="mail_to" size="30" value=""/> <input type="button" class="button" onClick="javascript:test_mail();" value="<?php echo L('mail_test_send')?>"></td>
                </tr>
            </table>
        </div>

        <div id="div_setting_upload" class="contentList pad-10 hidden" style="display:none;">
            <table width="100%"  class="table_form">
                <tr>
                    <th width="130" valign="top"><?php echo L('upload_maxsize')?></th>
                    <td class="y-bg"><input type="text" class="input-text" name="setting[upload_maxsize]" id="upload_maxsize" size="10" value="<?php echo $setting['upload_maxsize'] ? $setting['upload_maxsize'] : '2000' ?>"/> KB </td>
                </tr>
                <tr>
                    <th width="130" valign="top"><?php echo L('att_allow_ext')?></th>
                    <td class="y-bg"><input type="text" class="input-text" name="setting[upload_allowext]" id="upload_allowext" size="50" value="<?php echo $setting['upload_allowext']?>"/></td>
                </tr>  
                <tr>
                    <th><?php echo L('att_gb_check')?></th>
                    <td class="y-bg"><?php echo $this->check_gd()?></td>
                <tr>
                    <th><?php echo L('att_watermark_enable')?></th>
                    <td class="y-bg"><input class="radio_style" name="setting[watermark_enable]" value="1" <?php echo $setting['watermark_enable']==1 ? 'checked="checked"' : ''?> type="radio"> <?php echo L('att_watermark_open')?>&nbsp;&nbsp;&nbsp;&nbsp;<input class="radio_style" name="setting[watermark_enable]" value="0" <?php echo $setting['watermark_enable']==0 ? 'checked="checked"' : ''?> type="radio"> <?php echo L('att_watermark_close')?>
                    </td>
                </tr>

                <tr>
                    <th><?php echo L('att_watermark_condition')?></th>
                    <td class="y-bg"><?php echo L('att_watermark_minwidth');?><input type="text" class="input-text" name="setting[watermark_minwidth]" id="watermark_minwidth" size="10" value="<?php echo $setting['watermark_minwidth'] ? $setting['watermark_minwidth'] : '300' ?>" /> X <?php echo L('att_watermark_minheight')?><input type="text" class="input-text" name="setting[watermark_minheight]" id="watermark_minheight" size="10" value="<?php echo $setting['watermark_minheight'] ? $setting['watermark_minheight'] : '300' ?>" /> PX</td>
                </tr>
                <tr>
                    <th width="130" valign="top"><?php echo L('att_watermark_img')?></th>
                    <td class="y-bg"><input type="text" name="setting[watermark_img]" id="watermark_img" size="30" value="<?php echo $setting['watermark_img'] ? $setting['watermark_img'] : 'mark.gif' ?>"/><?php echo L('att_watermark_img_desc')?></td>
                </tr>

                <tr>
                    <th width="130" valign="top"><?php echo L('att_watermark_pct')?></th>
                    <td class="y-bg"><input type="text" class="input-text" name="setting[watermark_pct]" id="watermark_pct" size="10" value="<?php echo $setting['watermark_pct'] ? $setting['watermark_pct'] : '100' ?>" />  <?php echo L('att_watermark_pct_desc')?></td>
                </tr>
                <tr>
                    <th width="130" valign="top"><?php echo L('att_watermark_quality')?></th>
                    <td class="y-bg"><input type="text" class="input-text" name="setting[watermark_quality]" id="watermark_quality" size="10" value="<?php echo $setting['watermark_quality'] ? $setting['watermark_quality'] : '80' ?>" /> <?php echo L('att_watermark_quality_desc')?></td>
                </tr>
                <tr>
                    <th width="130" valign="top"><?php echo L('att_watermark_pos')?></th>
                    <td><table width="100%" class="radio-label">
                        <tr>
                            <td rowspan="3"><input class="radio_style" name="setting[watermark_pos]" value="10" type="radio" <?php echo ($setting['watermark_pos']==10) ? 'checked':''?>> <?php echo L('att_watermark_pos_10')?></td>
                            <td><input class="radio_style" name="setting[watermark_pos]" value="1" type="radio" <?php echo ($setting['watermark_pos']==1) ? 'checked':''?>> <?php echo L('att_watermark_pos_1')?></td>
                            <td><input class="radio_style" name="setting[watermark_pos]" value="2" type="radio" <?php echo ($setting['watermark_pos']==2) ? 'checked':'' ?>> <?php echo L('att_watermark_pos_2')?></td>
                            <td><input class="radio_style" name="setting[watermark_pos]" value="3" type="radio" <?php echo ($setting['watermark_pos']==3) ? 'checked':''?>> <?php echo L('att_watermark_pos_3')?></td>
                        </tr>
                        <tr>
                            <td><input class="radio_style" name="setting[watermark_pos]" value="4" type="radio" <?php echo ($setting['watermark_pos']==4) ? 'checked':''?>> <?php echo L('att_watermark_pos_4')?></td>
                            <td><input class="radio_style" name="setting[watermark_pos]" value="5" type="radio" <?php echo ($setting['watermark_pos']==5) ? 'checked':''?>> <?php echo L('att_watermark_pos_5')?></td>
                            <td><input class="radio_style" name="setting[watermark_pos]" value="6" type="radio" <?php echo ($setting['watermark_pos']==6) ? 'checked':''?>> <?php echo L('att_watermark_pos_6')?></td>
                        </tr>
                        <tr>
                            <td><input class="radio_style" name="setting[watermark_pos]" value="7" type="radio" <?php echo ($setting['watermark_pos']==7) ? 'checked':''?>> <?php echo L('att_watermark_pos_7')?></td>
                            <td><input class="radio_style" name="setting[watermark_pos]" value="8" type="radio" <?php echo ($setting['watermark_pos']==8) ? 'checked':''?>> <?php echo L('att_watermark_pos_8')?></td>
                            <td><input class="radio_style" name="setting[watermark_pos]" value="9" type="radio" <?php echo ($setting['watermark_pos']==9) ? 'checked':''?>> <?php echo L('att_watermark_pos_9')?></td>
                        </tr>
                    </table></td>
                </tr>
            </table>
</div>
<div class="bk15"></div>
<input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="button">
</div>
</div>
</form>
</body>
<script type="text/javascript">
function SwapTab(name,cls_show,cls_hide,cnt,cur) {
    $('div.contentList').hide();
    $('ul.tabBut > li').attr('class', cls_hide);
    $('#div_'+name+'_'+cur).show();
    $('#tab_'+name+'_'+cur).attr('class',cls_show);
}

function showsmtp(obj,hiddenid){
	hiddenid = hiddenid ? hiddenid : 'smtpcfg';
	var status = $(obj).val();
	if(status == 1) $("#"+hiddenid).show();
	else  $("#"+hiddenid).hide();
}
/* test_mail */
function test_mail() {
	var mail_type = $('input[checkbox=mail_type]:checked').val();
	var mail_auth = $('input[checkbox=mail_auth]:checked').val();
   	$.post('<?php echo U("Admin/Setting/public_test_mail");?>',{mail_to: $('#mail_to').val(),mail_type:mail_type,mail_server:$('#mail_server').val(),mail_port:$('#mail_port').val(),mail_user:$('#mail_user').val(),mail_password:$('#mail_password').val(),mail_auth:mail_auth,mail_from:$('#mail_from').val()}, function(data){
		alert(data);
	});
}
</script>
</html>